package jr;

import java.io.File;
import java.util.ArrayList;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader;

/**
 *
 * @author lucifer
 */
public class Reporter {

  public static JasperPrint ComprobanteTurnoReport(ArrayList<ComprobanteJR> data) throws JRException {
    JasperReport jr = (JasperReport) JRLoader.loadObject(Reporter.class.getResource("ComprobanteTurno.jasper"));
    JasperPrint jp = JasperFillManager.fillReport(jr, null, new JRBeanCollectionDataSource(data));
    return jp;
  }

  public static JasperPrint ComprobanteAsistenciaReport(ArrayList<ComprobanteJR> data) throws JRException {
    JasperReport jr = (JasperReport) JRLoader.loadObject(Reporter.class.getResource("ComprobanteAsistencia.jasper"));
    JasperPrint jp = JasperFillManager.fillReport(jr, null, new JRBeanCollectionDataSource(data));
    return jp;
  }

  public static JasperPrint ListadoDeTurnosReport(ArrayList<ListadoDeTurnosJR> data) throws JRException {
    JasperReport jr = (JasperReport) JRLoader.loadObject(Reporter.class.getResource("ListadoDeTurnos.jasper"));
    JasperPrint jp = JasperFillManager.fillReport(jr, null, new JRBeanCollectionDataSource(data));
    return jp;
  }

  public static JasperPrint LiquidacionObraSocialReport(ArrayList<LiquidacionJR> data) throws JRException {
    JasperReport jr = (JasperReport) JRLoader.loadObject(Reporter.class.getResource("LiquidacionObraSocial.jasper"));
    JasperPrint jp = JasperFillManager.fillReport(jr, null, new JRBeanCollectionDataSource(data));
    return jp;
  }

  public static JasperPrint LiquidacionParticularReport(ArrayList<LiquidacionJR> data) throws JRException {
    JasperReport jr = (JasperReport) JRLoader.loadObject(Reporter.class.getResource("LiquidacionParticular.jasper"));
    JasperPrint jp = JasperFillManager.fillReport(jr, null, new JRBeanCollectionDataSource(data));
    return jp;
  }

  public static void CopyPDFto(JasperPrint jp, String file) throws JRException {
    JRPdfExporter exporter = new JRPdfExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE, new File(file));
    exporter.exportReport();
  }

}
